package appnode;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Key;
import javax.jdo.annotations.Element;
import appnode.Interface;
import appnode.NodeRating;
import java.util.List;
import java.util.ArrayList;

@PersistenceCapable
public class Node {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

@Persistent
private String owner;

@Persistent
private String nodename;

@Persistent
private String lat;

@Persistent
private String lng;

@Persistent(mappedBy="node")
@Element(dependent="true")
private List<Interface> interfaces = new ArrayList<Interface>();

@Persistent
@Element(dependent="true")
private List<NodeRatings> noderatings = new ArrayList<NodeRatings>();

@Persistent
private Date date;

public Node(String owner, String nodename, String lat, String lng, Date date) {
	this.owner = owner;
	this.nodename = nodename;
	this.lat = lat;
	this.lng = lng;
	this.date = date;
}

public Key getKey() {
	return key;
}

public String getOwner() {
	return owner;
}

public String getNodename() {
	return nodename;
}

public String getLat() {
	return lat;
}

public String getLng() {
	return lng;
}

public List<Interface> getInterfaces() {
	return interfaces;
}

public List<NodeRatings> getNoderatings() {
	return noderatings;
}


public String getKeyStr() {
	return KeyFactory.keyToString(key);
}

public Date getDate() {
	return date;
}

public void setNodename(String nodename) {
	this.nodename = nodename;
}

public void setLat(String lat) {
	this.lat = lat;
}

public void setLng(String lng){
	this.lng = lng;
}

public void setInterfaces(List<Interface> interfaces) {
	this.interfaces = interfaces;
}

public void setNoderatings(List<NodeRatings> noderatings) {
	this.noderatings = noderatings;
}

public void setDate(Date date) {
	this.date=date;
}

}